/*     */ import java.awt.Color;
/*     */ import java.awt.Container;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Font;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Graphics2D;
/*     */ import java.awt.Insets;
/*     */ import java.awt.event.ActionEvent;
/*     */ import java.awt.event.ActionListener;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
/*     */ import java.awt.geom.Line2D.Double;
/*     */ import java.text.DecimalFormat;
/*     */ import java.util.Arrays;
/*     */ import java.util.List;
/*     */ import javax.swing.BorderFactory;
/*     */ import javax.swing.Box;
/*     */ import javax.swing.BoxLayout;
/*     */ import javax.swing.JButton;
/*     */ import javax.swing.JDialog;
/*     */ import javax.swing.JFrame;
/*     */ import javax.swing.JLabel;
/*     */ import javax.swing.JOptionPane;
/*     */ import javax.swing.JPanel;
/*     */ import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
/*     */ 
/*     */ public class DMIChart extends JPanel
/*     */   implements MouseMotionListener, BBIInterface, ActionListener
/*     */ {
/*     */   private SymQuotes sq;
/*     */   private String sym;
/*  14 */   private float yScale = 1.0F;
/*  15 */   private float xScale = 1.0F;
/*     */   private double stickWidth;
/*     */   private float minVal;
/*     */   private float maxVal;
/*     */   private int parm1;
/*     */   private int parm2;
/*     */   private float[] dmiPos_parm1;
/*     */   private float[] dmiNeg_parm1;
/*     */   private float[] adx_parm2;
/*  22 */   private String m = "";
/*     */   private int mX;
/*     */   private int mY;
/*  24 */   public int noOfDays = 150;
/*     */   private double p1Y;
/*     */   private double p2Y;
/*     */   private double p11Y;
/*     */   private double p22Y;
/*     */   private double p111Y;
/*     */   private double p222Y;
/*     */   private JTextField parm1TF;
/*     */   private JTextField parm2TF;
/*     */   private JButton chgParmOk;
/*     */   private JButton chgParmCancel;
/*     */   private JButton defaultParms;
/*     */   private JDialog chgParmDialog;
/*  32 */   private DecimalFormat df = new DecimalFormat("0.00");
/*     */ 
/*  34 */   public String trend = "";
/*     */   public DMIChart.EastPanel ep;
/*     */   private double refY;
/*     */   private double refX;
/* 589 */   private Font ssp10 = new Font("SansSerif", 0, 10);
/* 590 */   private Font ssp9 = new Font("SansSerif", 0, 9);
/* 591 */   private Line2D.Double refL1 = new Line2D.Double();
/* 592 */   private Line2D.Double refL2 = new Line2D.Double();
/* 593 */   private Line2D.Double gridY = new Line2D.Double();
/* 594 */   private Line2D.Double gridX = new Line2D.Double();
/* 595 */   private Line2D.Double yrefL1 = new Line2D.Double();
/* 596 */   private Line2D.Double yrefL2 = new Line2D.Double();
/*     */   private double yfactor;
/*     */   private double startPointX;
/*     */   private int dateRef;
/*     */   private int daysRef;
/* 601 */   private Line2D.Double l3 = new Line2D.Double();
/* 602 */   private Line2D.Double l1 = new Line2D.Double();
/* 603 */   private Line2D.Double l2 = new Line2D.Double();
/*     */   private double x1;
/*     */   private double y1;
/*     */   private double x2;
/*     */   private double y2;
/*     */   private double u1;
/*     */   private double v1;
/*     */   private double u2;
/*     */   private double v2;
/*     */   private double a1;
/*     */   private double b1;
/*     */   private double a2;
/*     */   private double b2;
/*     */   private double xi;
/*     */   private double yi;
/* 605 */   private Line2D.Double uA = new Line2D.Double();
/* 606 */   private Line2D.Double lA = new Line2D.Double();
/* 607 */   private Line2D.Double hA = new Line2D.Double();
/*     */ 
/*     */   public DMIChart(SymQuotes paramSymQuotes, int paramInt1, int paramInt2)
/*     */   {
/*  39 */     this.sq = paramSymQuotes;
/*  40 */     this.sym = paramSymQuotes.sym;
/*     */ 
/*  42 */     this.dmiPos_parm1 = new float[paramSymQuotes.count];
/*  43 */     this.dmiNeg_parm1 = new float[paramSymQuotes.count];
/*  44 */     this.adx_parm2 = new float[paramSymQuotes.count];
/*     */ 
/*  46 */     this.parm1 = paramInt1;
/*  47 */     this.parm2 = paramInt2;
/*     */ 
/*  49 */     if (this.noOfDays == 150)
/*  50 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/*  52 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/*  54 */     setBackground(Color.black);
/*  55 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */ 
/*  57 */     if (paramInt1 < paramSymQuotes.count) {
/*  58 */       dmi_parm1Finder();
/*     */     }
/*  60 */     if (paramInt1 + paramInt2 < paramSymQuotes.count) {
/*  61 */       adx_parm2Finder();
/*     */     }
/*  63 */     findMinMax();
/*  64 */     addMouseMotionListener(this);
/*     */ 
/*  66 */     if (this.dmiPos_parm1[(paramSymQuotes.count - 1)] >= this.dmiNeg_parm1[(paramSymQuotes.count - 1)])
/*  67 */       this.trend = "Bullish";
/*     */     else {
/*  69 */       this.trend = "Bearish";
/*     */     }
/*  71 */     this.ep = new DMIChart.EastPanel();
/*     */   }
/*     */ 
/*     */   public int getBBIdata(int paramInt)
/*     */   {
/*  78 */     if (this.dmiPos_parm1[paramInt] >= this.dmiNeg_parm1[paramInt]) {
/*  79 */       return 1;
/*     */     }
/*  81 */     return 0;
/*     */   }
/*     */ 
/*     */   public void changeNoOfDays(int paramInt)
/*     */   {
/*  88 */     this.noOfDays = paramInt;
/*     */ 
/*  90 */     if (paramInt == 150)
/*  91 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/*  93 */       this.stickWidth = (1.5D * this.xScale);
/*  94 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public void redrawChart(SymQuotes paramSymQuotes)
/*     */   {
/* 101 */     this.sq = paramSymQuotes;
/* 102 */     this.sym = paramSymQuotes.sym;
/*     */ 
/* 104 */     this.dmiPos_parm1 = new float[paramSymQuotes.count];
/* 105 */     this.dmiNeg_parm1 = new float[paramSymQuotes.count];
/* 106 */     this.adx_parm2 = new float[paramSymQuotes.count];
/*     */ 
/* 108 */     if (this.noOfDays == 150)
/* 109 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/* 111 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/* 113 */     if (this.parm1 < paramSymQuotes.count) {
/* 114 */       dmi_parm1Finder();
/*     */     }
/* 116 */     if (this.parm1 + this.parm2 < paramSymQuotes.count) {
/* 117 */       adx_parm2Finder();
/*     */     }
/* 119 */     findMinMax();
/*     */ 
/* 121 */     if (this.dmiPos_parm1[(paramSymQuotes.count - 1)] >= this.dmiNeg_parm1[(paramSymQuotes.count - 1)])
/* 122 */       this.trend = "Bullish";
/*     */     else {
/* 124 */       this.trend = "Bearish";
/*     */     }
/* 126 */     repaint();
/* 127 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void redrawChart()
/*     */   {
/* 134 */     Arrays.fill(this.dmiPos_parm1, 0.0F);
/* 135 */     Arrays.fill(this.dmiNeg_parm1, 0.0F);
/* 136 */     Arrays.fill(this.adx_parm2, 0.0F);
/*     */ 
/* 138 */     if (this.parm1 < this.sq.count) {
/* 139 */       dmi_parm1Finder();
/*     */     }
/* 141 */     if (this.parm1 + this.parm2 < this.sq.count) {
/* 142 */       adx_parm2Finder();
/*     */     }
/* 144 */     findMinMax();
/*     */ 
/* 146 */     if (this.dmiPos_parm1[(this.sq.count - 1)] >= this.dmiNeg_parm1[(this.sq.count - 1)])
/* 147 */       this.trend = "Bullish";
/*     */     else {
/* 149 */       this.trend = "Bearish";
/*     */     }
/* 151 */     repaint();
/* 152 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void mouseMoved(MouseEvent paramMouseEvent)
/*     */   {
/* 160 */     int j = 1;
/* 161 */     if ((paramMouseEvent.getX() >= 50) && (paramMouseEvent.getX() <= 750.0F * this.xScale + 50.0F) && (paramMouseEvent.getY() >= 10) && (paramMouseEvent.getY() <= this.yScale * 100.0F + 10.0F))
/*     */     {
/* 163 */       int i = (int)((750.0F * this.xScale - (paramMouseEvent.getX() - 50) - this.stickWidth / 2.0D) / (this.stickWidth + 1.0F * this.xScale));
/*     */ 
/* 165 */       if (this.sq.count - 1 >= i)
/*     */       {
/* 167 */         j = this.sq.count - 1 - i;
/* 168 */         this.m = ("( " + (String)this.sq.date.get(j) + ", DMI+[" + this.parm1 + "]:" + this.df.format(this.dmiPos_parm1[j]) + "  DMI-[" + this.parm1 + "]:" + this.df.format(this.dmiNeg_parm1[j]) + "  ADX[" + this.parm2 + "]:" + this.df.format(this.adx_parm2[j]) + " )");
/*     */ 
/* 171 */         this.mX = paramMouseEvent.getX();
/* 172 */         this.mY = paramMouseEvent.getY();
/* 173 */         repaint();
/* 174 */         return;
/*     */       }
/*     */ 
/* 178 */       this.m = "";
/*     */ 
/* 180 */       repaint();
/* 181 */       return;
/*     */     }
/*     */ 
/* 185 */     this.m = "";
/* 186 */     repaint();
/*     */   }
/*     */ 
/*     */   public void mouseDragged(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ 
/*     */   private void drawValues(Graphics2D paramGraphics2D)
/*     */   {
/* 199 */     paramGraphics2D.setPaint(Color.cyan);
/*     */ 
/* 201 */     if (this.mX + this.m.length() * 5 > 750.0F * this.xScale + 50.0F) {
/* 202 */       this.mX -= this.m.length() * 5;
/*     */     }
/* 204 */     paramGraphics2D.drawString(this.m, this.mX, this.mY);
/*     */   }
/*     */ 
/*     */   private void dmi_parm1Finder()
/*     */   {
/* 211 */     for (int i = 0; i < this.parm1; i++) {
/* 212 */       this.dmiPos_parm1[i] = 0.0F;
/* 213 */       this.dmiNeg_parm1[i] = 0.0F;
/*     */     }
/*     */ 
/* 216 */     for (int i = this.parm1; i < this.sq.count; i++)
/*     */     {
/* 218 */       float f1 = 0.0F;
/* 219 */       float f2 = 0.0F;
/* 220 */       float f3 = 0.0F;
/* 221 */       float f4 = 0.0F;
/* 222 */       float f5 = 0.0F;
/* 223 */       float f6 = 0.0F;
/*     */ 
/* 225 */       for (int j = i; j > i - this.parm1; j--)
/*     */       {
/* 227 */         float f7 = 0.0F;
/* 228 */         float f8 = 0.0F;
/* 229 */         float f9 = 0.0F;
/* 230 */         if (((Float)this.sq.high.get(j)).floatValue() > ((Float)this.sq.high.get(j - 1)).floatValue()) {
/* 231 */           f7 = ((Float)this.sq.high.get(j)).floatValue() - ((Float)this.sq.high.get(j - 1)).floatValue();
/*     */         }
/* 233 */         if (((Float)this.sq.low.get(j)).floatValue() < ((Float)this.sq.low.get(j - 1)).floatValue()) {
/* 234 */           f8 = ((Float)this.sq.low.get(j - 1)).floatValue() - ((Float)this.sq.low.get(j)).floatValue();
/*     */         }
/* 236 */         if (f7 > f8) {
/* 237 */           f1 += f7;
/*     */         }
/* 239 */         if (f8 > f7) {
/* 240 */           f2 += f8;
/*     */         }
/* 242 */         if ((((Float)this.sq.high.get(j)).floatValue() - ((Float)this.sq.low.get(j)).floatValue() > ((Float)this.sq.high.get(j)).floatValue() - ((Float)this.sq.close.get(j - 1)).floatValue()) && (((Float)this.sq.high.get(j)).floatValue() - ((Float)this.sq.low.get(j)).floatValue() > ((Float)this.sq.low.get(j)).floatValue() - ((Float)this.sq.close.get(j - 1)).floatValue()))
/*     */         {
/* 244 */           f9 = ((Float)this.sq.high.get(j)).floatValue() - ((Float)this.sq.low.get(j)).floatValue();
/* 245 */         }if ((((Float)this.sq.high.get(j)).floatValue() - ((Float)this.sq.close.get(j - 1)).floatValue() > ((Float)this.sq.high.get(j)).floatValue() - ((Float)this.sq.low.get(j)).floatValue()) && (((Float)this.sq.high.get(j)).floatValue() - ((Float)this.sq.close.get(j - 1)).floatValue() > ((Float)this.sq.low.get(j)).floatValue() - ((Float)this.sq.close.get(j - 1)).floatValue()))
/*     */         {
/* 247 */           f9 = ((Float)this.sq.high.get(j)).floatValue() - ((Float)this.sq.close.get(j - 1)).floatValue();
/* 248 */         }if ((((Float)this.sq.low.get(j)).floatValue() - ((Float)this.sq.close.get(j - 1)).floatValue() > ((Float)this.sq.high.get(j)).floatValue() - ((Float)this.sq.low.get(j)).floatValue()) && (((Float)this.sq.low.get(j)).floatValue() - ((Float)this.sq.close.get(j - 1)).floatValue() > ((Float)this.sq.high.get(j)).floatValue() - ((Float)this.sq.close.get(j - 1)).floatValue()))
/*     */         {
/* 250 */           f9 = ((Float)this.sq.low.get(j)).floatValue() - ((Float)this.sq.close.get(j - 1)).floatValue();
/*     */         }
/* 252 */         f3 += f9;
/*     */       }
/*     */ 
/* 255 */       f4 = f1 / this.parm1;
/* 256 */       f5 = f2 / this.parm1;
/* 257 */       f6 = f3 / this.parm1;
/*     */ 
/* 259 */       this.dmiPos_parm1[i] = (f4 / (f6 + 1.0F) * 100.0F);
/* 260 */       this.dmiNeg_parm1[i] = (f5 / (f6 + 1.0F) * 100.0F);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void adx_parm2Finder()
/*     */   {
/* 268 */     for (int i = 0; i < this.parm1 + this.parm2; i++) {
/* 269 */       this.adx_parm2[i] = 0.0F;
/*     */     }
/* 271 */     for (int i = this.parm1 + this.parm2; i < this.sq.count; i++)
/*     */     {
/* 273 */       float f1 = 0.0F;
/* 274 */       for (int j = i; j > i - this.parm2; j--)
/*     */       {
/* 276 */         float f2 = 0.0F;
/* 277 */         float f3 = 0.0F;
/*     */ 
/* 279 */         f2 = Math.abs(this.dmiPos_parm1[j] - this.dmiNeg_parm1[j]);
/* 280 */         f3 = this.dmiPos_parm1[j] + this.dmiNeg_parm1[j];
/*     */ 
/* 282 */         f1 += f2 / (f3 + 1.0F) * 100.0F;
/*     */       }
/*     */ 
/* 285 */       this.adx_parm2[i] = (f1 / this.parm2);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void findMinMax()
/*     */   {
/* 293 */     int i = 1;
/* 294 */     this.minVal = this.dmiPos_parm1[(this.sq.count - 1)];
/* 295 */     this.maxVal = this.dmiPos_parm1[(this.sq.count - 1)];
/*     */ 
/* 297 */     for (int j = this.sq.count - 1; j >= this.parm1; j--)
/*     */     {
/* 299 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 302 */       if (this.minVal > this.dmiPos_parm1[j]) {
/* 303 */         this.minVal = this.dmiPos_parm1[j];
/*     */       }
/* 305 */       if (this.maxVal < this.dmiPos_parm1[j]) {
/* 306 */         this.maxVal = this.dmiPos_parm1[j];
/*     */       }
/* 308 */       i += 1;
/*     */     }
/*     */ 
/* 312 */     i = 1;
int j;
/* 313 */     for (j = this.sq.count - 1; j >= this.parm1; j--)
/*     */     {
/* 315 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 318 */       if (this.minVal > this.dmiNeg_parm1[j]) {
/* 319 */         this.minVal = this.dmiNeg_parm1[j];
/*     */       }
/* 321 */       if (this.maxVal < this.dmiNeg_parm1[j]) {
/* 322 */         this.maxVal = this.dmiNeg_parm1[j];
/*     */       }
/* 324 */       i += 1;
/*     */     }
/*     */ 
/* 328 */     i = 1;
/* 329 */     for (j = this.sq.count - 1; j >= this.parm1 + this.parm2; j--)
/*     */     {
/* 331 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 334 */       if (this.minVal > this.adx_parm2[j]) {
/* 335 */         this.minVal = this.adx_parm2[j];
/*     */       }
/* 337 */       if (this.maxVal < this.adx_parm2[j]) {
/* 338 */         this.maxVal = this.adx_parm2[j];
/*     */       }
/* 340 */       i += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void updateParms(int paramInt1, int paramInt2)
/*     */   {
/* 351 */     this.parm1 = paramInt1;
/* 352 */     this.parm2 = paramInt2;
/*     */ 
/* 354 */     dmi_parm1Finder();
/* 355 */     adx_parm2Finder();
/* 356 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public Box getDMIBox(boolean paramBoolean)
/*     */   {
/* 363 */     Box localBox = Box.createHorizontalBox();
/* 364 */     TitledBorder localTitledBorder = BorderFactory.createTitledBorder("DMI");
/*     */ 
/* 366 */     this.parm1TF = new JTextField("" + this.parm1, 2);
/* 367 */     this.parm2TF = new JTextField("" + this.parm2, 2);
/* 368 */     this.parm1TF.setFont(this.ssp10);
/* 369 */     this.parm2TF.setFont(this.ssp10);
/* 370 */     this.parm1TF.setMaximumSize(new Dimension(25, 20));
/* 371 */     this.parm2TF.setMaximumSize(new Dimension(25, 20));
/*     */ 
/* 373 */     JLabel localJLabel1 = new JLabel("DMI[");
/* 374 */     JLabel localJLabel2 = new JLabel("] ,  ADX[");
/* 375 */     JLabel localJLabel3 = new JLabel("]     ");
/*     */ 
/* 377 */     localJLabel1.setFont(this.ssp10);
/* 378 */     localJLabel2.setFont(this.ssp10);
/* 379 */     localJLabel3.setFont(this.ssp10);
/*     */ 
/* 381 */     localBox.add(localJLabel1);
/* 382 */     localBox.add(this.parm1TF);
/* 383 */     localBox.add(localJLabel2);
/* 384 */     localBox.add(this.parm2TF);
/* 385 */     localBox.add(localJLabel3);
/*     */ 
/* 387 */     localBox.add(Box.createHorizontalGlue());
/*     */ 
/* 389 */     if (paramBoolean) {
/* 390 */       localBox.setBorder(localTitledBorder);
/*     */     }
/* 392 */     return localBox;
/*     */   }
/*     */ 
/*     */   public void showChgParmDialog()
/*     */   {
/* 399 */     JFrame localJFrame = new JFrame();
/* 400 */     this.chgParmDialog = new JDialog(localJFrame, "Change DMI Parameters", true);
/* 401 */     Box localBox1 = Box.createVerticalBox();
/* 402 */     Box localBox2 = Box.createHorizontalBox();
/*     */ 
/* 404 */     this.chgParmOk = new JButton("OK");
/* 405 */     this.chgParmOk.setFont(this.ssp10);
/* 406 */     this.chgParmOk.setMargin(new Insets(1, 2, 1, 2));
/* 407 */     this.chgParmOk.addActionListener(this);
/*     */ 
/* 409 */     this.chgParmCancel = new JButton("Cancel");
/* 410 */     this.chgParmCancel.setFont(this.ssp10);
/* 411 */     this.chgParmCancel.setMargin(new Insets(1, 2, 1, 2));
/* 412 */     this.chgParmCancel.addActionListener(this);
/*     */ 
/* 414 */     this.defaultParms = new JButton("Default");
/* 415 */     this.defaultParms.setFont(this.ssp10);
/* 416 */     this.defaultParms.setMargin(new Insets(1, 2, 1, 2));
/* 417 */     this.defaultParms.setToolTipText("Reset to default parameters");
/* 418 */     this.defaultParms.addActionListener(this);
/*     */ 
/* 420 */     localBox2.add(Box.createHorizontalGlue());
/* 421 */     localBox2.add(this.chgParmOk);
/* 422 */     localBox2.add(Box.createHorizontalStrut(5));
/* 423 */     localBox2.add(this.chgParmCancel);
/* 424 */     localBox2.add(Box.createHorizontalStrut(5));
/* 425 */     localBox2.add(this.defaultParms);
/* 426 */     localBox2.add(Box.createHorizontalGlue());
/*     */ 
/* 428 */     localBox1.add(getDMIBox(true));
/* 429 */     localBox1.add(localBox2);
/*     */ 
/* 431 */     this.chgParmDialog.getContentPane().add(localBox1);
/* 432 */     this.chgParmDialog.setSize(250, 100);
/* 433 */     this.chgParmDialog.setLocationRelativeTo(this.ep);
/* 434 */     this.chgParmDialog.setVisible(true);
/*     */   }
/*     */ 
/*     */   public boolean validateParm()
/*     */   {
/* 441 */     int i = this.parm1;
/* 442 */     int j = this.parm2;
/*     */     try
/*     */     {
/* 446 */       i = Integer.parseInt(this.parm1TF.getText().trim());
/* 447 */       j = Integer.parseInt(this.parm2TF.getText().trim());
/*     */     }
/*     */     catch (NumberFormatException localNumberFormatException)
/*     */     {
/* 453 */       JOptionPane.showMessageDialog(null, "Error in DMI parameter.Enter only numbers greater than 2.", null, 0);
/*     */ 
/* 456 */       this.parm1TF.setText("" + this.parm1);
/* 457 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 459 */       return false;
/*     */     }
/*     */ 
/* 463 */     if ((i > 200) || (j > 200))
/*     */     {
/* 465 */       JOptionPane.showMessageDialog(null, "Error in DMI parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 468 */       this.parm1TF.setText("" + this.parm1);
/* 469 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 471 */       return false;
/*     */     }
/*     */ 
/* 475 */     if ((i < 2) || (j < 2))
/*     */     {
/* 477 */       JOptionPane.showMessageDialog(null, "Error in DMI parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 480 */       this.parm1TF.setText("" + this.parm1);
/* 481 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 483 */       return false;
/*     */     }
/*     */ 
/* 487 */     this.parm1 = i;
/* 488 */     this.parm2 = j;
/*     */ 
/* 490 */     return true;
/*     */   }
/*     */ 
/*     */   public void actionPerformed(ActionEvent paramActionEvent)
/*     */   {
/* 497 */     if (paramActionEvent.getSource() == this.chgParmOk)
/*     */     {
/* 499 */       if (!validateParm()) {
/* 500 */         return;
/*     */       }
/* 502 */       redrawChart();
/* 503 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 507 */     if (paramActionEvent.getSource() == this.chgParmCancel)
/*     */     {
/* 509 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 513 */     if (paramActionEvent.getSource() == this.defaultParms)
/*     */     {
/* 515 */       setDefaultParms();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setDefaultParms()
/*     */   {
/* 523 */     this.parm1TF.setText("14");
/* 524 */     this.parm2TF.setText("14");
/*     */   }
/*     */ 
/*     */   public void vZoom(boolean paramBoolean)
/*     */   {
/* 531 */     if (paramBoolean)
/* 532 */       this.yScale += 0.2F;
/* 533 */     else if (this.yScale >= 1.2F) {
/* 534 */       this.yScale -= 0.2F;
/*     */     }
/* 536 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void hZoom(boolean paramBoolean)
/*     */   {
/* 543 */     if (paramBoolean)
/* 544 */       this.xScale += 0.2F;
/* 545 */     else if (this.xScale >= 1.2F) {
/* 546 */       this.xScale -= 0.2F;
/*     */     }
/* 548 */     if (this.noOfDays == 150)
/* 549 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 551 */       this.stickWidth = (1.5D * this.xScale);
/* 552 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void resetZoom()
/*     */   {
/* 559 */     this.yScale = 1.0F;
/* 560 */     this.xScale = 1.0F;
/* 561 */     if (this.noOfDays == 150)
/* 562 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 564 */       this.stickWidth = (1.5D * this.xScale);
/* 565 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   protected void clear(Graphics paramGraphics)
/*     */   {
/* 572 */     super.paintComponent(paramGraphics);
/*     */   }
/*     */ 
/*     */   protected void paintComponent(Graphics paramGraphics)
/*     */   {
/* 579 */     clear(paramGraphics);
/* 580 */     Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
/* 581 */     drawChart(localGraphics2D);
/* 582 */     drawValues(localGraphics2D);
/*     */   }
/*     */ 
/*     */   private void drawChart(Graphics2D paramGraphics2D)
/*     */   {
/* 612 */     this.refY = 10.0D;
/* 613 */     this.refX = 50.0D;
/* 614 */     setFont(this.ssp10);
/* 615 */     String str = "Directional Movement Index";
/* 616 */     paramGraphics2D.setPaint(new Color(100, 240, 250));
/* 617 */     paramGraphics2D.drawString(str, 50, 10);
/*     */ 
/* 619 */     str = "DMI+[" + this.parm1 + "]";
/* 620 */     paramGraphics2D.setPaint(new Color(210, 210, 20));
/* 621 */     paramGraphics2D.drawString(str, 195, 10);
/*     */ 
/* 623 */     str = "DMI-[" + this.parm1 + "]";
/* 624 */     paramGraphics2D.setPaint(new Color(80, 150, 125));
/* 625 */     paramGraphics2D.drawString(str, 245, 10);
/*     */ 
/* 627 */     str = "ADX[" + this.parm2 + "]";
/* 628 */     paramGraphics2D.setPaint(new Color(0, 150, 125));
/* 629 */     paramGraphics2D.drawString(str, 295, 10);
/*     */ 
/* 632 */     this.refL1.setLine(50.0D, 10.0D, 50.0D, this.yScale * 100.0F + 10.0F);
/* 633 */     this.refL2.setLine(750.0F * this.xScale + 50.0F, 10.0D, 750.0F * this.xScale + 50.0F, this.yScale * 100.0F + 10.0F);
/* 634 */     paramGraphics2D.setPaint(Color.white);
/* 635 */     paramGraphics2D.draw(this.refL1);
/* 636 */     paramGraphics2D.draw(this.refL2);
/*     */ 
/* 638 */     for (int i = 0; i < 14; i++)
/*     */     {
/* 640 */       this.refX += 50.0F * this.xScale;
/* 641 */       this.gridY.setLine(this.refX, 10.0D, this.refX, this.yScale * 100.0F + 10.0F);
/* 642 */       paramGraphics2D.setPaint(Color.darkGray);
/* 643 */       paramGraphics2D.draw(this.gridY);
/*     */     }
int i;
/*     */ 
/* 647 */     for (i = 0; i < 11; i++)
/*     */     {
/* 649 */       this.yrefL1.setLine(50.0D, this.refY, 40.0D, this.refY);
/* 650 */       str = this.df.format(this.maxVal - (this.maxVal - this.minVal) / 10.0F * i);
/* 651 */       paramGraphics2D.setPaint(Color.lightGray);
/* 652 */       paramGraphics2D.drawString(str, 10, (int)this.refY);
/* 653 */       this.yrefL2.setLine(750.0F * this.xScale + 50.0F, this.refY, 750.0F * this.xScale + 60.0F, this.refY);
/*     */ 
/* 655 */       paramGraphics2D.drawString(str, (int)(750.0F * this.xScale + 53.0F), (int)this.refY);
/* 656 */       this.gridX.setLine(50.0D, this.refY, 750.0F * this.xScale + 50.0F, this.refY);
/* 657 */       paramGraphics2D.setPaint(Color.white);
/* 658 */       paramGraphics2D.draw(this.yrefL1);
/* 659 */       paramGraphics2D.draw(this.yrefL2);
/* 660 */       paramGraphics2D.setPaint(Color.darkGray);
/* 661 */       paramGraphics2D.draw(this.gridX);
/* 662 */       this.refY += 10.0F * this.yScale;
/*     */     }
/*     */ 
/* 666 */     this.yfactor = (this.yScale * 100.0F / (this.maxVal - this.minVal));
/* 667 */     this.startPointX = (750.0F * this.xScale + 50.0F - (this.stickWidth + 1.0F * this.xScale));
/* 668 */     this.dateRef = (this.sq.count - 1);
/* 669 */     this.daysRef = 1;
/*     */ 
/* 672 */     for (i = this.sq.count - 1; i > this.parm1; i--)
/*     */     {
/* 674 */       if (this.daysRef == this.noOfDays)
/*     */         break;
/* 676 */       paramGraphics2D.setFont(this.ssp10);
/*     */ 
/* 679 */       if (i > this.parm1)
/*     */       {
/* 681 */         this.p1Y = (this.yScale * 100.0F + 10.0F - (this.dmiPos_parm1[i] - this.minVal) * this.yfactor);
/* 682 */         this.p2Y = (this.yScale * 100.0F + 10.0F - (this.dmiPos_parm1[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 684 */         this.l1.setLine(this.startPointX, this.p1Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p2Y);
/* 685 */         paramGraphics2D.setPaint(new Color(210, 210, 20));
/* 686 */         paramGraphics2D.draw(this.l1);
/*     */       }
/*     */ 
/* 690 */       if (i > this.parm1)
/*     */       {
/* 692 */         this.p11Y = (this.yScale * 100.0F + 10.0F - (this.dmiNeg_parm1[i] - this.minVal) * this.yfactor);
/* 693 */         this.p22Y = (this.yScale * 100.0F + 10.0F - (this.dmiNeg_parm1[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 695 */         this.l2.setLine(this.startPointX, this.p11Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p22Y);
/* 696 */         paramGraphics2D.setPaint(new Color(80, 150, 125));
/* 697 */         paramGraphics2D.draw(this.l2);
/*     */       }
/*     */ 
/* 701 */       if (i > this.parm1 + this.parm2)
/*     */       {
/* 703 */         this.p111Y = (this.yScale * 100.0F + 10.0F - (this.adx_parm2[i] - this.minVal) * this.yfactor);
/* 704 */         this.p222Y = (this.yScale * 100.0F + 10.0F - (this.adx_parm2[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 706 */         this.l3.setLine(this.startPointX, this.p111Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p222Y);
/* 707 */         paramGraphics2D.setPaint(new Color(0, 150, 125));
/* 708 */         paramGraphics2D.draw(this.l3);
/*     */       }
/*     */ 
/* 713 */       if ((i > this.parm1) && (this.dmiPos_parm1[i] - this.dmiNeg_parm1[i] >= 0.0F) && (this.dmiPos_parm1[(i - 1)] - this.dmiNeg_parm1[(i - 1)] < 0.0F))
/*     */       {
/* 715 */         this.x1 = this.startPointX;
/* 716 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 717 */         this.y1 = this.p1Y;
/* 718 */         this.y2 = this.p2Y;
/* 719 */         this.u1 = this.x1;
/* 720 */         this.u2 = this.x2;
/* 721 */         this.v1 = this.p11Y;
/* 722 */         this.v2 = this.p22Y;
/*     */ 
/* 724 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 725 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 727 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 728 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 730 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 731 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 733 */         paramGraphics2D.setPaint(Color.green);
/* 734 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 735 */         this.lA.setLine(this.xi, this.yi - 5.0D, this.xi - 3.0D, this.yi);
/* 736 */         this.hA.setLine(this.xi, this.yi - 5.0D, this.xi + 3.0D, this.yi);
/* 737 */         paramGraphics2D.draw(this.uA);
/* 738 */         paramGraphics2D.draw(this.lA);
/* 739 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 743 */       if ((i > this.parm1) && (this.dmiPos_parm1[i] - this.dmiNeg_parm1[i] < 0.0F) && (this.dmiPos_parm1[(i - 1)] - this.dmiNeg_parm1[(i - 1)] > 0.0F))
/*     */       {
/* 745 */         this.x1 = this.startPointX;
/* 746 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 747 */         this.y1 = this.p1Y;
/* 748 */         this.y2 = this.p2Y;
/* 749 */         this.u1 = this.x1;
/* 750 */         this.u2 = this.x2;
/* 751 */         this.v1 = this.p11Y;
/* 752 */         this.v2 = this.p22Y;
/*     */ 
/* 754 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 755 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 757 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 758 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 760 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 761 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 763 */         paramGraphics2D.setPaint(Color.red);
/* 764 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 765 */         this.lA.setLine(this.xi, this.yi + 5.0D, this.xi - 3.0D, this.yi);
/* 766 */         this.hA.setLine(this.xi, this.yi + 5.0D, this.xi + 3.0D, this.yi);
/* 767 */         paramGraphics2D.draw(this.uA);
/* 768 */         paramGraphics2D.draw(this.lA);
/* 769 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 773 */       if (this.dateRef == i)
/*     */       {
/* 775 */         paramGraphics2D.setFont(this.ssp9);
/* 776 */         str = ((String)this.sq.date.get(i)).substring(0, 6);
/* 777 */         if (this.dmiPos_parm1[i] >= this.dmiNeg_parm1[i])
/* 778 */           paramGraphics2D.setPaint(Color.green);
/*     */         else {
/* 780 */           paramGraphics2D.setPaint(Color.red);
/*     */         }
/* 782 */         paramGraphics2D.drawString(str, (int)this.startPointX, (int)(this.yScale * 100.0F + 20.0F));
/* 783 */         if (this.noOfDays == 150)
/* 784 */           this.dateRef -= 10;
/*     */         else
/* 786 */           this.dateRef -= 20;
/* 787 */         paramGraphics2D.setFont(this.ssp10);
/*     */       }
/*     */ 
/* 791 */       this.startPointX = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 792 */       this.daysRef += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   public static void main(String[] paramArrayOfString)
/*     */   {
/* 859 */     FileDownloader localFileDownloader = new FileDownloader();
/* 860 */     localFileDownloader.downloadFiles();
/* 861 */     SymQuotes localSymQuotes = new SymQuotes("WIPRO", localFileDownloader.datesToRead, 1, 1, "ns");
/*     */ 
/* 863 */     DMIChart localDMIChart = new DMIChart(localSymQuotes, 14, 14);
/*     */ 
/* 865 */     JFrame localJFrame = new JFrame("Test");
/* 866 */     localJFrame.setDefaultCloseOperation(3);
/* 867 */     localJFrame.getContentPane().add(localDMIChart);
/* 868 */     localJFrame.pack();
/* 869 */     localJFrame.setSize(850, 175);
/* 870 */     localJFrame.setVisible(true);
/*     */   }
/*     */ 
/*     */   public class EastPanel extends JPanel
/*     */   {
/*     */     private JLabel title;
/*     */     private JLabel dmiPosL;
/*     */     private JLabel dmiNegL;
/*     */     private JLabel adxL;
/*     */     private JLabel trendL;
/*     */     private ChartHelpButton chb;
/* 804 */     private Font valuesF = new Font("Sanserif", 0, 11);
/* 805 */     public Box buttonsPanel = Box.createHorizontalBox();
/*     */ 
/*     */     public EastPanel()
/*     */     {
/* 809 */       this.title = new JLabel("DMI");
/* 810 */       this.dmiPosL = new JLabel("DMI+[" + DMIChart.this.parm1 + "]: " + DMIChart.this.df.format(DMIChart.this.dmiPos_parm1[(DMIChart.this.sq.count - 1)]));
/* 811 */       this.dmiNegL = new JLabel("DMI-[" + DMIChart.this.parm1 + "]: " + DMIChart.this.df.format(DMIChart.this.dmiNeg_parm1[(DMIChart.this.sq.count - 1)]));
/* 812 */       this.adxL = new JLabel("ADX[" + DMIChart.this.parm2 + "]: " + DMIChart.this.df.format(DMIChart.this.adx_parm2[(DMIChart.this.sq.count - 1)]));
/*     */ 
/* 814 */       this.trendL = new JLabel("Trend: " + DMIChart.this.trend);
/* 815 */       this.chb = new ChartHelpButton("http://www.profitindicators.com/home/indicators/dmi.htm", "Help on DMI");
/*     */ 
/* 817 */       this.chb.setFont(this.valuesF);
/*     */ 
/* 819 */       this.dmiPosL.setFont(this.valuesF);
/* 820 */       this.dmiNegL.setFont(this.valuesF);
/* 821 */       this.trendL.setFont(this.valuesF);
/* 822 */       this.adxL.setFont(this.valuesF);
/*     */ 
/* 824 */       this.buttonsPanel.add(this.chb);
/* 825 */       this.buttonsPanel.add(Box.createHorizontalStrut(2));
/* 826 */       this.buttonsPanel.setAlignmentX(0.0F);
/*     */ 
/* 828 */       setLayout(new BoxLayout(this, 3));
/*     */ 
/* 830 */       add(this.title);
/* 831 */       add(this.dmiPosL);
/* 832 */       add(this.dmiNegL);
/* 833 */       add(this.adxL);
/* 834 */       add(new JLabel(" "));
/* 835 */       add(this.trendL);
/* 836 */       add(this.buttonsPanel);
/* 837 */       add(Box.createVerticalGlue());
/*     */ 
/* 839 */       setBackground(new Color(243, 245, 252));
/*     */     }
/*     */ 
/*     */     public void updateValues()
/*     */     {
/* 846 */       this.dmiPosL.setText("DMI+[" + DMIChart.this.parm1 + "]: " + DMIChart.this.df.format(DMIChart.this.dmiPos_parm1[(DMIChart.this.sq.count - 1)]));
/* 847 */       this.dmiNegL.setText("DMI-[" + DMIChart.this.parm1 + "]: " + DMIChart.this.df.format(DMIChart.this.dmiNeg_parm1[(DMIChart.this.sq.count - 1)]));
/* 848 */       this.adxL.setText("ADX[" + DMIChart.this.parm2 + "]: " + DMIChart.this.df.format(DMIChart.this.adx_parm2[(DMIChart.this.sq.count - 1)]));
/* 849 */       this.trendL.setText("Trend: " + DMIChart.this.trend);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Deebak\Downloads\profitindicatorsv2-05.jar
 * Qualified Name:     DMIChart
 * JD-Core Version:    0.6.0
 */